﻿using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;

namespace AVISOutBound.SSOServer.Migrations
{
    public partial class AddOrdersEntity : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_ClientClaims_Clients_ClientId",
                table: "ClientClaims");

            migrationBuilder.DropForeignKey(
                name: "FK_ClientCorsOrigins_Clients_ClientId",
                table: "ClientCorsOrigins");

            migrationBuilder.DropForeignKey(
                name: "FK_ClientGrantTypes_Clients_ClientId",
                table: "ClientGrantTypes");

            migrationBuilder.DropForeignKey(
                name: "FK_ClientIdPRestrictions_Clients_ClientId",
                table: "ClientIdPRestrictions");

            migrationBuilder.DropForeignKey(
                name: "FK_ClientPostLogoutRedirectUris_Clients_ClientId",
                table: "ClientPostLogoutRedirectUris");

            migrationBuilder.DropForeignKey(
                name: "FK_ClientProperties_Clients_ClientId",
                table: "ClientProperties");

            migrationBuilder.DropForeignKey(
                name: "FK_ClientRedirectUris_Clients_ClientId",
                table: "ClientRedirectUris");

            migrationBuilder.DropForeignKey(
                name: "FK_ClientScopes_Clients_ClientId",
                table: "ClientScopes");

            migrationBuilder.DropForeignKey(
                name: "FK_ClientSecrets_Clients_ClientId",
                table: "ClientSecrets");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ClientSecrets",
                table: "ClientSecrets");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ClientScopes",
                table: "ClientScopes");

            migrationBuilder.DropIndex(
                name: "IX_Clients_ClientId",
                table: "Clients");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ClientRedirectUris",
                table: "ClientRedirectUris");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ClientProperties",
                table: "ClientProperties");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ClientPostLogoutRedirectUris",
                table: "ClientPostLogoutRedirectUris");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ClientIdPRestrictions",
                table: "ClientIdPRestrictions");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ClientGrantTypes",
                table: "ClientGrantTypes");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ClientCorsOrigins",
                table: "ClientCorsOrigins");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ClientClaims",
                table: "ClientClaims");

            migrationBuilder.DropIndex(
                name: "IX_AbpPersistedGrants_SubjectId_ClientId_Type",
                table: "AbpPersistedGrants");

            migrationBuilder.RenameTable(
                name: "ClientSecrets",
                newName: "ClientSecret");

            migrationBuilder.RenameTable(
                name: "ClientScopes",
                newName: "ClientScope");

            migrationBuilder.RenameTable(
                name: "ClientRedirectUris",
                newName: "ClientRedirectUri");

            migrationBuilder.RenameTable(
                name: "ClientProperties",
                newName: "ClientProperty");

            migrationBuilder.RenameTable(
                name: "ClientPostLogoutRedirectUris",
                newName: "ClientPostLogoutRedirectUri");

            migrationBuilder.RenameTable(
                name: "ClientIdPRestrictions",
                newName: "ClientIdPRestriction");

            migrationBuilder.RenameTable(
                name: "ClientGrantTypes",
                newName: "ClientGrantType");

            migrationBuilder.RenameTable(
                name: "ClientCorsOrigins",
                newName: "ClientCorsOrigin");

            migrationBuilder.RenameTable(
                name: "ClientClaims",
                newName: "ClientClaim");

            migrationBuilder.RenameIndex(
                name: "IX_ClientSecrets_ClientId",
                table: "ClientSecret",
                newName: "IX_ClientSecret_ClientId");

            migrationBuilder.RenameIndex(
                name: "IX_ClientScopes_ClientId",
                table: "ClientScope",
                newName: "IX_ClientScope_ClientId");

            migrationBuilder.RenameIndex(
                name: "IX_ClientRedirectUris_ClientId",
                table: "ClientRedirectUri",
                newName: "IX_ClientRedirectUri_ClientId");

            migrationBuilder.RenameIndex(
                name: "IX_ClientProperties_ClientId",
                table: "ClientProperty",
                newName: "IX_ClientProperty_ClientId");

            migrationBuilder.RenameIndex(
                name: "IX_ClientPostLogoutRedirectUris_ClientId",
                table: "ClientPostLogoutRedirectUri",
                newName: "IX_ClientPostLogoutRedirectUri_ClientId");

            migrationBuilder.RenameIndex(
                name: "IX_ClientIdPRestrictions_ClientId",
                table: "ClientIdPRestriction",
                newName: "IX_ClientIdPRestriction_ClientId");

            migrationBuilder.RenameIndex(
                name: "IX_ClientGrantTypes_ClientId",
                table: "ClientGrantType",
                newName: "IX_ClientGrantType_ClientId");

            migrationBuilder.RenameIndex(
                name: "IX_ClientCorsOrigins_ClientId",
                table: "ClientCorsOrigin",
                newName: "IX_ClientCorsOrigin_ClientId");

            migrationBuilder.RenameIndex(
                name: "IX_ClientClaims_ClientId",
                table: "ClientClaim",
                newName: "IX_ClientClaim_ClientId");

            migrationBuilder.AlterColumn<string>(
                name: "Value",
                table: "ClientSecret",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 2000);

            migrationBuilder.AlterColumn<string>(
                name: "Type",
                table: "ClientSecret",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 250,
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Description",
                table: "ClientSecret",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 2000,
                oldNullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "ClientId",
                table: "ClientSecret",
                nullable: true,
                oldClrType: typeof(int));

            migrationBuilder.AlterColumn<string>(
                name: "Scope",
                table: "ClientScope",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 200);

            migrationBuilder.AlterColumn<int>(
                name: "ClientId",
                table: "ClientScope",
                nullable: true,
                oldClrType: typeof(int));

            migrationBuilder.AlterColumn<string>(
                name: "ProtocolType",
                table: "Clients",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 200);

            migrationBuilder.AlterColumn<string>(
                name: "PairWiseSubjectSalt",
                table: "Clients",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 200,
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "LogoUri",
                table: "Clients",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 2000,
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "FrontChannelLogoutUri",
                table: "Clients",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 2000,
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Description",
                table: "Clients",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 1000,
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "ClientUri",
                table: "Clients",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 2000,
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "ClientName",
                table: "Clients",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 200,
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "ClientId",
                table: "Clients",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 200);

            migrationBuilder.AlterColumn<string>(
                name: "ClientClaimsPrefix",
                table: "Clients",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 200,
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "BackChannelLogoutUri",
                table: "Clients",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 2000,
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "RedirectUri",
                table: "ClientRedirectUri",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 2000);

            migrationBuilder.AlterColumn<int>(
                name: "ClientId",
                table: "ClientRedirectUri",
                nullable: true,
                oldClrType: typeof(int));

            migrationBuilder.AlterColumn<string>(
                name: "Value",
                table: "ClientProperty",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 2000);

            migrationBuilder.AlterColumn<string>(
                name: "Key",
                table: "ClientProperty",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 250);

            migrationBuilder.AlterColumn<int>(
                name: "ClientId",
                table: "ClientProperty",
                nullable: true,
                oldClrType: typeof(int));

            migrationBuilder.AlterColumn<string>(
                name: "PostLogoutRedirectUri",
                table: "ClientPostLogoutRedirectUri",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 2000);

            migrationBuilder.AlterColumn<int>(
                name: "ClientId",
                table: "ClientPostLogoutRedirectUri",
                nullable: true,
                oldClrType: typeof(int));

            migrationBuilder.AlterColumn<string>(
                name: "Provider",
                table: "ClientIdPRestriction",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 200);

            migrationBuilder.AlterColumn<int>(
                name: "ClientId",
                table: "ClientIdPRestriction",
                nullable: true,
                oldClrType: typeof(int));

            migrationBuilder.AlterColumn<string>(
                name: "GrantType",
                table: "ClientGrantType",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 250);

            migrationBuilder.AlterColumn<int>(
                name: "ClientId",
                table: "ClientGrantType",
                nullable: true,
                oldClrType: typeof(int));

            migrationBuilder.AlterColumn<string>(
                name: "Origin",
                table: "ClientCorsOrigin",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 150);

            migrationBuilder.AlterColumn<int>(
                name: "ClientId",
                table: "ClientCorsOrigin",
                nullable: true,
                oldClrType: typeof(int));

            migrationBuilder.AlterColumn<string>(
                name: "Value",
                table: "ClientClaim",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 250);

            migrationBuilder.AlterColumn<string>(
                name: "Type",
                table: "ClientClaim",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 250);

            migrationBuilder.AlterColumn<int>(
                name: "ClientId",
                table: "ClientClaim",
                nullable: true,
                oldClrType: typeof(int));

            migrationBuilder.AlterColumn<string>(
                name: "Type",
                table: "AbpPersistedGrants",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 50);

            migrationBuilder.AlterColumn<string>(
                name: "SubjectId",
                table: "AbpPersistedGrants",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 200,
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Data",
                table: "AbpPersistedGrants",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 50000);

            migrationBuilder.AlterColumn<string>(
                name: "ClientId",
                table: "AbpPersistedGrants",
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 200);

            migrationBuilder.AlterColumn<string>(
                name: "Id",
                table: "AbpPersistedGrants",
                nullable: false,
                oldClrType: typeof(string),
                oldMaxLength: 200);

            migrationBuilder.AddPrimaryKey(
                name: "PK_ClientSecret",
                table: "ClientSecret",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ClientScope",
                table: "ClientScope",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ClientRedirectUri",
                table: "ClientRedirectUri",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ClientProperty",
                table: "ClientProperty",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ClientPostLogoutRedirectUri",
                table: "ClientPostLogoutRedirectUri",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ClientIdPRestriction",
                table: "ClientIdPRestriction",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ClientGrantType",
                table: "ClientGrantType",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ClientCorsOrigin",
                table: "ClientCorsOrigin",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ClientClaim",
                table: "ClientClaim",
                column: "Id");

            migrationBuilder.CreateTable(
                name: "AbgExchangeRateses",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    CurrencyCode = table.Column<string>(maxLength: 50, nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    LowExchangeRate = table.Column<float>(nullable: true),
                    RMBExchangeRate = table.Column<float>(nullable: true),
                    RealTimeExchangeRate = table.Column<float>(nullable: true),
                    Remark = table.Column<string>(maxLength: 200, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AbgExchangeRateses", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "AbgOrderPayLogs",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Amount = table.Column<float>(nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    OrderNo = table.Column<string>(maxLength: 50, nullable: true),
                    OutOrderNo = table.Column<string>(maxLength: 64, nullable: true),
                    PayType = table.Column<int>(nullable: true),
                    Remark = table.Column<string>(maxLength: 200, nullable: true),
                    Status = table.Column<int>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AbgOrderPayLogs", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "AbgRefundOrders",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Amount = table.Column<float>(nullable: true),
                    Cause = table.Column<int>(nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    OrderNo = table.Column<string>(maxLength: 50, nullable: true),
                    OutRefundOrderNo = table.Column<string>(maxLength: 64, nullable: true),
                    Reason = table.Column<string>(maxLength: 200, nullable: true),
                    RefundOrderNo = table.Column<string>(maxLength: 64, nullable: true),
                    RefundType = table.Column<int>(nullable: true),
                    RefundWay = table.Column<int>(nullable: true),
                    Remark = table.Column<string>(maxLength: 200, nullable: true),
                    SellMemo = table.Column<string>(maxLength: 200, nullable: true),
                    UserId = table.Column<long>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AbgRefundOrders", x => x.Id);
                });

   

            migrationBuilder.AddForeignKey(
                name: "FK_ClientClaim_Clients_ClientId",
                table: "ClientClaim",
                column: "ClientId",
                principalTable: "Clients",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_ClientCorsOrigin_Clients_ClientId",
                table: "ClientCorsOrigin",
                column: "ClientId",
                principalTable: "Clients",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_ClientGrantType_Clients_ClientId",
                table: "ClientGrantType",
                column: "ClientId",
                principalTable: "Clients",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_ClientIdPRestriction_Clients_ClientId",
                table: "ClientIdPRestriction",
                column: "ClientId",
                principalTable: "Clients",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_ClientPostLogoutRedirectUri_Clients_ClientId",
                table: "ClientPostLogoutRedirectUri",
                column: "ClientId",
                principalTable: "Clients",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_ClientProperty_Clients_ClientId",
                table: "ClientProperty",
                column: "ClientId",
                principalTable: "Clients",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_ClientRedirectUri_Clients_ClientId",
                table: "ClientRedirectUri",
                column: "ClientId",
                principalTable: "Clients",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_ClientScope_Clients_ClientId",
                table: "ClientScope",
                column: "ClientId",
                principalTable: "Clients",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_ClientSecret_Clients_ClientId",
                table: "ClientSecret",
                column: "ClientId",
                principalTable: "Clients",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_ClientClaim_Clients_ClientId",
                table: "ClientClaim");

            migrationBuilder.DropForeignKey(
                name: "FK_ClientCorsOrigin_Clients_ClientId",
                table: "ClientCorsOrigin");

            migrationBuilder.DropForeignKey(
                name: "FK_ClientGrantType_Clients_ClientId",
                table: "ClientGrantType");

            migrationBuilder.DropForeignKey(
                name: "FK_ClientIdPRestriction_Clients_ClientId",
                table: "ClientIdPRestriction");

            migrationBuilder.DropForeignKey(
                name: "FK_ClientPostLogoutRedirectUri_Clients_ClientId",
                table: "ClientPostLogoutRedirectUri");

            migrationBuilder.DropForeignKey(
                name: "FK_ClientProperty_Clients_ClientId",
                table: "ClientProperty");

            migrationBuilder.DropForeignKey(
                name: "FK_ClientRedirectUri_Clients_ClientId",
                table: "ClientRedirectUri");

            migrationBuilder.DropForeignKey(
                name: "FK_ClientScope_Clients_ClientId",
                table: "ClientScope");

            migrationBuilder.DropForeignKey(
                name: "FK_ClientSecret_Clients_ClientId",
                table: "ClientSecret");

            migrationBuilder.DropTable(
                name: "AbgExchangeRateses");

            migrationBuilder.DropTable(
                name: "AbgOrderPayLogs");

            migrationBuilder.DropTable(
                name: "AbgRefundOrders");

            migrationBuilder.DropTable(
                name: "avisOBOrder");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ClientSecret",
                table: "ClientSecret");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ClientScope",
                table: "ClientScope");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ClientRedirectUri",
                table: "ClientRedirectUri");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ClientProperty",
                table: "ClientProperty");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ClientPostLogoutRedirectUri",
                table: "ClientPostLogoutRedirectUri");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ClientIdPRestriction",
                table: "ClientIdPRestriction");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ClientGrantType",
                table: "ClientGrantType");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ClientCorsOrigin",
                table: "ClientCorsOrigin");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ClientClaim",
                table: "ClientClaim");

            migrationBuilder.RenameTable(
                name: "ClientSecret",
                newName: "ClientSecrets");

            migrationBuilder.RenameTable(
                name: "ClientScope",
                newName: "ClientScopes");

            migrationBuilder.RenameTable(
                name: "ClientRedirectUri",
                newName: "ClientRedirectUris");

            migrationBuilder.RenameTable(
                name: "ClientProperty",
                newName: "ClientProperties");

            migrationBuilder.RenameTable(
                name: "ClientPostLogoutRedirectUri",
                newName: "ClientPostLogoutRedirectUris");

            migrationBuilder.RenameTable(
                name: "ClientIdPRestriction",
                newName: "ClientIdPRestrictions");

            migrationBuilder.RenameTable(
                name: "ClientGrantType",
                newName: "ClientGrantTypes");

            migrationBuilder.RenameTable(
                name: "ClientCorsOrigin",
                newName: "ClientCorsOrigins");

            migrationBuilder.RenameTable(
                name: "ClientClaim",
                newName: "ClientClaims");

            migrationBuilder.RenameIndex(
                name: "IX_ClientSecret_ClientId",
                table: "ClientSecrets",
                newName: "IX_ClientSecrets_ClientId");

            migrationBuilder.RenameIndex(
                name: "IX_ClientScope_ClientId",
                table: "ClientScopes",
                newName: "IX_ClientScopes_ClientId");

            migrationBuilder.RenameIndex(
                name: "IX_ClientRedirectUri_ClientId",
                table: "ClientRedirectUris",
                newName: "IX_ClientRedirectUris_ClientId");

            migrationBuilder.RenameIndex(
                name: "IX_ClientProperty_ClientId",
                table: "ClientProperties",
                newName: "IX_ClientProperties_ClientId");

            migrationBuilder.RenameIndex(
                name: "IX_ClientPostLogoutRedirectUri_ClientId",
                table: "ClientPostLogoutRedirectUris",
                newName: "IX_ClientPostLogoutRedirectUris_ClientId");

            migrationBuilder.RenameIndex(
                name: "IX_ClientIdPRestriction_ClientId",
                table: "ClientIdPRestrictions",
                newName: "IX_ClientIdPRestrictions_ClientId");

            migrationBuilder.RenameIndex(
                name: "IX_ClientGrantType_ClientId",
                table: "ClientGrantTypes",
                newName: "IX_ClientGrantTypes_ClientId");

            migrationBuilder.RenameIndex(
                name: "IX_ClientCorsOrigin_ClientId",
                table: "ClientCorsOrigins",
                newName: "IX_ClientCorsOrigins_ClientId");

            migrationBuilder.RenameIndex(
                name: "IX_ClientClaim_ClientId",
                table: "ClientClaims",
                newName: "IX_ClientClaims_ClientId");

            migrationBuilder.AlterColumn<string>(
                name: "Value",
                table: "ClientSecrets",
                maxLength: 2000,
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Type",
                table: "ClientSecrets",
                maxLength: 250,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Description",
                table: "ClientSecrets",
                maxLength: 2000,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "ClientId",
                table: "ClientSecrets",
                nullable: false,
                oldClrType: typeof(int),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Scope",
                table: "ClientScopes",
                maxLength: 200,
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "ClientId",
                table: "ClientScopes",
                nullable: false,
                oldClrType: typeof(int),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "ProtocolType",
                table: "Clients",
                maxLength: 200,
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "PairWiseSubjectSalt",
                table: "Clients",
                maxLength: 200,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "LogoUri",
                table: "Clients",
                maxLength: 2000,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "FrontChannelLogoutUri",
                table: "Clients",
                maxLength: 2000,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Description",
                table: "Clients",
                maxLength: 1000,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "ClientUri",
                table: "Clients",
                maxLength: 2000,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "ClientName",
                table: "Clients",
                maxLength: 200,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "ClientId",
                table: "Clients",
                maxLength: 200,
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "ClientClaimsPrefix",
                table: "Clients",
                maxLength: 200,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "BackChannelLogoutUri",
                table: "Clients",
                maxLength: 2000,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "RedirectUri",
                table: "ClientRedirectUris",
                maxLength: 2000,
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "ClientId",
                table: "ClientRedirectUris",
                nullable: false,
                oldClrType: typeof(int),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Value",
                table: "ClientProperties",
                maxLength: 2000,
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Key",
                table: "ClientProperties",
                maxLength: 250,
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "ClientId",
                table: "ClientProperties",
                nullable: false,
                oldClrType: typeof(int),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "PostLogoutRedirectUri",
                table: "ClientPostLogoutRedirectUris",
                maxLength: 2000,
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "ClientId",
                table: "ClientPostLogoutRedirectUris",
                nullable: false,
                oldClrType: typeof(int),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Provider",
                table: "ClientIdPRestrictions",
                maxLength: 200,
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "ClientId",
                table: "ClientIdPRestrictions",
                nullable: false,
                oldClrType: typeof(int),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "GrantType",
                table: "ClientGrantTypes",
                maxLength: 250,
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "ClientId",
                table: "ClientGrantTypes",
                nullable: false,
                oldClrType: typeof(int),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Origin",
                table: "ClientCorsOrigins",
                maxLength: 150,
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "ClientId",
                table: "ClientCorsOrigins",
                nullable: false,
                oldClrType: typeof(int),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Value",
                table: "ClientClaims",
                maxLength: 250,
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Type",
                table: "ClientClaims",
                maxLength: 250,
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "ClientId",
                table: "ClientClaims",
                nullable: false,
                oldClrType: typeof(int),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Type",
                table: "AbpPersistedGrants",
                maxLength: 50,
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "SubjectId",
                table: "AbpPersistedGrants",
                maxLength: 200,
                nullable: true,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Data",
                table: "AbpPersistedGrants",
                maxLength: 50000,
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "ClientId",
                table: "AbpPersistedGrants",
                maxLength: 200,
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Id",
                table: "AbpPersistedGrants",
                maxLength: 200,
                nullable: false,
                oldClrType: typeof(string));

            migrationBuilder.AddPrimaryKey(
                name: "PK_ClientSecrets",
                table: "ClientSecrets",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ClientScopes",
                table: "ClientScopes",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ClientRedirectUris",
                table: "ClientRedirectUris",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ClientProperties",
                table: "ClientProperties",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ClientPostLogoutRedirectUris",
                table: "ClientPostLogoutRedirectUris",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ClientIdPRestrictions",
                table: "ClientIdPRestrictions",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ClientGrantTypes",
                table: "ClientGrantTypes",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ClientCorsOrigins",
                table: "ClientCorsOrigins",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ClientClaims",
                table: "ClientClaims",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Clients_ClientId",
                table: "Clients",
                column: "ClientId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_AbpPersistedGrants_SubjectId_ClientId_Type",
                table: "AbpPersistedGrants",
                columns: new[] { "SubjectId", "ClientId", "Type" });

            migrationBuilder.AddForeignKey(
                name: "FK_ClientClaims_Clients_ClientId",
                table: "ClientClaims",
                column: "ClientId",
                principalTable: "Clients",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ClientCorsOrigins_Clients_ClientId",
                table: "ClientCorsOrigins",
                column: "ClientId",
                principalTable: "Clients",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ClientGrantTypes_Clients_ClientId",
                table: "ClientGrantTypes",
                column: "ClientId",
                principalTable: "Clients",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ClientIdPRestrictions_Clients_ClientId",
                table: "ClientIdPRestrictions",
                column: "ClientId",
                principalTable: "Clients",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ClientPostLogoutRedirectUris_Clients_ClientId",
                table: "ClientPostLogoutRedirectUris",
                column: "ClientId",
                principalTable: "Clients",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ClientProperties_Clients_ClientId",
                table: "ClientProperties",
                column: "ClientId",
                principalTable: "Clients",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ClientRedirectUris_Clients_ClientId",
                table: "ClientRedirectUris",
                column: "ClientId",
                principalTable: "Clients",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ClientScopes_Clients_ClientId",
                table: "ClientScopes",
                column: "ClientId",
                principalTable: "Clients",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ClientSecrets_Clients_ClientId",
                table: "ClientSecrets",
                column: "ClientId",
                principalTable: "Clients",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
